package com.sss.demo.web;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;

/**
 * 所有的Controller都继承的父类
 * @author zhaoqiang
 * @company Spring Airlines,Spring Tour
 */
@Controller
public class BaseController {
	/**
	 * 定义日志log4j输出工具
	 */
	private final static Logger LOG=Logger.getLogger(BaseController.class);
	
	/**
	 * log4j输出info级别日志
	 * @param info
	 */
	protected void logInfo(String info){
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		LOG.info(info+" @ "+format.format(new Date(System.currentTimeMillis())));
	}
	
	/**
	 * log4j输出Error级别日志
	 * @param info
	 */
	protected void logErr(String info){
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		LOG.error(info+" @ "+format.format(new Date(System.currentTimeMillis())));
	}
	
	/**
	 * log4j输出warn级别日志
	 * @param info
	 */
	protected void logWarn(String info){
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		LOG.warn(info+" @ "+format.format(new Date(System.currentTimeMillis())));
	}
}
